package com.prolificinteractive.materialcalendarview.sample.slice;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.utils.Color;

import com.prolificinteractive.materialcalendarview.sample.BasicAbility;
import com.prolificinteractive.materialcalendarview.sample.BasicAbilityDecorated;
import com.prolificinteractive.materialcalendarview.sample.CustomTileDimensions;
import com.prolificinteractive.materialcalendarview.sample.CustomizeCodeAbility;
import com.prolificinteractive.materialcalendarview.sample.CustomizeXmlAbility;
import com.prolificinteractive.materialcalendarview.sample.DialogsAbility;
import com.prolificinteractive.materialcalendarview.sample.DisableDaysAbility;
import com.prolificinteractive.materialcalendarview.sample.DynamicSettersAbility;
import com.prolificinteractive.materialcalendarview.sample.GettersAbility;
import com.prolificinteractive.materialcalendarview.sample.MultipleSizeAbility;
import com.prolificinteractive.materialcalendarview.sample.MultipleViewAbility;
import com.prolificinteractive.materialcalendarview.sample.OldCalendarViewAbility;
import com.prolificinteractive.materialcalendarview.sample.ResourceTable;
import com.prolificinteractive.materialcalendarview.sample.RotationAbility;
import com.prolificinteractive.materialcalendarview.sample.SelectionModesAbility;
import com.prolificinteractive.materialcalendarview.sample.SwappableBasicAbilityDecorated;
import com.prolificinteractive.materialcalendarview.sample.tools.FontCache;


public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener {
    private Button button_old_calendar;
    private Button button_basic;
    private Button button_selections;
    private Button button_decorators;
    private Button button_title_activity_basic_modes;
    private Button button_disable;
    private Button button_customize_xml;
    private Button button_customize_code;
    private Button button_dynamic_setters;
    private Button button_custom_tile_size;
    private Button button_dialogs;
    private Button button_multiple_view;
    private Button button_multiple_size;
    private Button button_getters;
    private Button button_rotation;

    private Intent intent;
    private Operation operation;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        getWindow().setStatusBarColor(Color.getIntColor("#0093FF"));
        initComponent();
    }

    private void initComponent() {
        button_old_calendar = (Button) findComponentById(ResourceTable.Id_button_old_calendar);
        button_old_calendar.setClickedListener(this);
        button_basic = (Button) findComponentById(ResourceTable.Id_button_basic);
        button_basic.setClickedListener(this);
        button_selections = (Button) findComponentById(ResourceTable.Id_button_selections);
        button_selections.setClickedListener(this);
        button_decorators = (Button) findComponentById(ResourceTable.Id_button_decorators);
        button_decorators.setClickedListener(this);
        button_title_activity_basic_modes = (Button) findComponentById(ResourceTable.Id_button_title_activity_basic_modes);
        button_title_activity_basic_modes.setClickedListener(this);
        button_disable = (Button) findComponentById(ResourceTable.Id_button_disable);
        button_disable.setClickedListener(this);
        button_customize_xml = (Button) findComponentById(ResourceTable.Id_button_customize_xml);
        button_customize_xml.setClickedListener(this);
        button_customize_code = (Button) findComponentById(ResourceTable.Id_button_customize_code);
        button_customize_code.setClickedListener(this);
        button_dynamic_setters = (Button) findComponentById(ResourceTable.Id_button_dynamic_setters);
        button_dynamic_setters.setClickedListener(this);
        button_custom_tile_size = (Button) findComponentById(ResourceTable.Id_button_custom_tile_size);
        button_custom_tile_size.setClickedListener(this);
        button_dialogs = (Button) findComponentById(ResourceTable.Id_button_dialogs);
        button_dialogs.setClickedListener(this);
        button_multiple_view = (Button) findComponentById(ResourceTable.Id_button_multiple_view);
        button_multiple_view.setClickedListener(this);
        button_multiple_size = (Button) findComponentById(ResourceTable.Id_button_multiple_size);
        button_multiple_size.setClickedListener(this);
        button_getters = (Button) findComponentById(ResourceTable.Id_button_getters);
        button_getters.setClickedListener(this);
        button_rotation = (Button) findComponentById(ResourceTable.Id_button_rotation);
        button_rotation.setClickedListener(this);

    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()) {
            case ResourceTable.Id_button_old_calendar:
                startAbility(OldCalendarViewAbility.class.getName());
                break;
            case ResourceTable.Id_button_basic:
                startAbility(BasicAbility.class.getName());
                break;
            case ResourceTable.Id_button_selections:
                startAbility(SelectionModesAbility.class.getName());
                break;
            case ResourceTable.Id_button_decorators:
                startAbility(BasicAbilityDecorated.class.getName());
                break;
            case ResourceTable.Id_button_title_activity_basic_modes:
                startAbility(SwappableBasicAbilityDecorated.class.getName());
                break;
            case ResourceTable.Id_button_disable:
                startAbility(DisableDaysAbility.class.getName());
                break;
            case ResourceTable.Id_button_customize_xml:
                startAbility(CustomizeXmlAbility.class.getName());
                break;
            case ResourceTable.Id_button_customize_code:
                startAbility(CustomizeCodeAbility.class.getName());
                break;
            case ResourceTable.Id_button_dynamic_setters:
                startAbility(DynamicSettersAbility.class.getName());
                break;
            case ResourceTable.Id_button_custom_tile_size:
                startAbility(CustomTileDimensions.class.getName());
                break;
            case ResourceTable.Id_button_dialogs:
                startAbility(DialogsAbility.class.getName());
                break;
            case ResourceTable.Id_button_multiple_view:
                startAbility(MultipleViewAbility.class.getName());
                break;
            case ResourceTable.Id_button_multiple_size:
                startAbility(MultipleSizeAbility.class.getName());
                break;
            case ResourceTable.Id_button_getters:
                startAbility(GettersAbility.class.getName());
                break;
            case ResourceTable.Id_button_rotation:
                startAbility(RotationAbility.class.getName());
                break;
            default:
                break;
        }
    }

    private void startAbility(String abilityName) {
        intent = new Intent();
        operation = new Intent.OperationBuilder()
            .withBundleName(getBundleName())
            .withAbilityName(abilityName)
            .build();
        intent.setOperation(operation);
        startAbility(intent);
    }
}
